package com.jinqing.wuchuang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.jinqing.wuchuang.entity.SettledPush;
import com.jinqing.wuchuang.mapper.SettledPushMapper;
import com.jinqing.wuchuang.service.PushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class PushServiceImpl implements PushService {

    @Autowired
    SettledPushMapper settledPushMapper;

    /**
     * 查询所有用户
     * @return
     */
    @Override
    public List<SettledPush> selectAllUser() {
        List<SettledPush> users = settledPushMapper.selectList(null);
        return users;
    }

    @Override
    @Transactional(isolation = Isolation.READ_COMMITTED)
    public int updatePayStatus(SettledPush settledPush) {
        settledPush.setPay(false);
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.eq("uid",settledPush.getUid());
        int updateResult = settledPushMapper.update(settledPush,updateWrapper);
        return updateResult;
    }
}
